﻿namespace SAFPodcast.WP8.DAL.LocalBDD
{
    public class DataContextHelper
    {
        public static PodcastsDataContext GetInstance()
        {
            return new PodcastsDataContext(PodcastsDataContext.DBConnectionString);
        }

        public static void InitializeDB()
        {
            DataContextHelper.InitializeDB(PodcastsDataContext.DBConnectionString);
        }

        public static void InitializeDB(string dbConnectionString)
        {
            using (PodcastsDataContext db = new PodcastsDataContext(dbConnectionString))
            {
                if (!db.DatabaseExists())
                {
                    //Create the database
                    db.CreateDatabase();
                }
#if false
                else
                {
                    db.DeleteDatabase();
                    db.CreateDatabase();
                }
#endif
            }
        }
    }
}
